<?
include "../model/model.php";

function get_category_data(){
	
	$category_data = get_category();
	return $category_data;
}
function show_category($company_name, $num){
	$category_data = get_category_data();
	for($i=1; $i<=count($category_data); $i++){
		if($company_name == null){
		echo "<li> <a href=","http://117.17.102.203/view/category.html?company_name=$category_data[$i]&i=$i",">";
		echo "$category_data[$i] ";
		echo "</a></li>";
		}else{
			for($j=1; $j<=$num-1; $j++){
				echo "<li> <a href=","http://117.17.102.203/view/category.html?company_name=$category_data[$j]&i=$j",">";
				echo "$category_data[$j] ";
				echo "</a></li>";
			}
			echo "<li>";
			echo "<a href=","http://117.17.102.203/view/category.html?company_name=$category_data[$i]&i=$i",">";
			echo "$category_data[$num]";
			echo "</a><ul>";
			//제품명들 들어갈 부분
			$product_name = get_product_name($company_name);
			for($k=1; $k <= count($product_name); $k++) {
			 echo "<div class='names'>";
				echo "<li>";
				echo "<a href=","http://117.17.102.203/view/product.html?product_name=$product_name[$k]"," target=","main",">",$product_name[$k],"</a>";
				echo"</li>";
			
			}
			echo "</ul>";
			//제품명들 종료
			for($j=$num+1; $j<=count($category_data); $j++)
			{
			if($category_data[$j] == null){}
			else{
				echo "<li> <a href=","http://117.17.102.203/view/category.html?company_name=$category_data[$j]&i=$j",">";	
				echo "$category_data[$j] ";
				echo "</a></li>";
				}
			
			}
			return 0;
		}

		
	}
}
?>